<?php

namespace App\Admin\Controllers;

use App\alipay;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class AlipayController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App\alipay';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new alipay());

        $grid->filter(function($filter){

            // 去掉默认的id过滤器
            $filter->disableIdFilter();

            // 在这里添加字段过滤器
            $filter->like('EnterpriseName', '企业名称');

        });

        $grid->column('EnterpriseName', __('企业名称'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Email', __('登录邮箱'))->display(function($text) {
            return str_limit($text, 12, '...');
        });
        $grid->column('Password', __('登录密码'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('PaymentPwd', __('支付密码'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Phone', __('注册手机'));
        $grid->column('RegistrationTime', __('注册时间'));
        $grid->column('Status', __('认证状态'));
        $grid->column('Question1', __('安全问题1'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Answer1', __('答案1'));
        $grid->column('Question2', __('安全问题2'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Answer2', __('答案2'));
        $grid->column('Question3', __('安全问题3'))->display(function($text) {
            return str_limit($text, 12, '...');
        });;
        $grid->column('Answer3', __('答案3'));
        $grid->column('Remarks', __('备注'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(alipay::findOrFail($id));


        $show->field('EnterpriseName', __('企业名称'));
        $show->field('Email', __('登录邮箱'));
        $show->field('Password', __('登录密码'));
        $show->field('PaymentPwd', __('支付密码'));
        $show->field('Phone', __('注册手机'));
        $show->field('RegistrationTime', __('注册时间'));
        $show->field('Status', __('认证状态'));
        $show->field('Question1', __('安全问题1'));
        $show->field('Answer1', __('答案1'));
        $show->field('Question2', __('安全问题2'));
        $show->field('Answer2', __('答案2'));
        $show->field('Question3', __('安全问题3'));
        $show->field('Answer3', __('答案3'));
        $show->field('Remarks', __('备注'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new alipay());


        $form->text('EnterpriseName', __('企业名称'));
        $form->email('Email', __('登录邮箱'));
        $form->password('Password', __('登录密码'));
        $form->password('PaymentPwd', __('支付密码'));
        $form->mobile('Phone', __('注册手机'));
        $form->datetime('RegistrationTime', __('注册时间'));
        $form->text('Status', __('认证状态'));
        $form->text('Question1', __('安全问题1'));
        $form->text('Answer1', __('答案1'));
        $form->text('Question2', __('安全问题2'));
        $form->text('Answer2', __('答案2'));
        $form->text('Question3', __('安全问题3'));
        $form->text('Answer3', __('答案3'));
        $form->text('Remarks', __('备注'));

        return $form;
    }
}
